<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>第五题</title>
</head>

<body>
    <script>
        let flag = true
        while (flag === true) {
            let num1 = +prompt('请输入你的出生日期')
            if (num1 < 2022 && num1 > 0) {
                let cha = 2022 - num1
                console.log(num1)
                alert(`你今年${cha}岁了`)
                break
                flag = false
            } else {
                alert('请输入正确的出生日期')
            }
        }

    </script>
</body>

</html>